package com.orchard.orchardfarmmanagementsystem.controller;


import com.orchard.orchardfarmmanagementsystem.dto.EvaluationDTO;
import com.orchard.orchardfarmmanagementsystem.entity.User;
import com.orchard.orchardfarmmanagementsystem.service.EvaluationService;
import com.orchard.orchardfarmmanagementsystem.service.UserService;
import com.orchard.orchardfarmmanagementsystem.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/api")
public class EvaluationController {
    @Autowired
    private EvaluationService evaluationService;

    @PostMapping("/tasks/{taskId}/evaluate")
    @PreAuthorize("hasAuthority('PERM_ADMIN_DASHBOARD')")
    public Result submitTaskEvaluation(@PathVariable Integer taskId,
                                       @RequestBody EvaluationDTO evaluationDTO) {
        try {
            return evaluationService.submitTaskEvaluation(taskId,evaluationDTO);

        } catch (Exception e) {
            return Result.error(50001,"评价任务失败");
        }
    }
}